﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Weibo4Sharp.Model;
using Hammock.Web;

namespace Weibo4Sharp.Service
{
    public partial class WeiboService
    {
        public virtual IEnumerable<WeiboTrend> ListTrendsFor(long userId, int count = 10, int page = 1)
        {
            return WithHammock<IEnumerable<WeiboTrend>>("trends", FormatAsString,
                "?user_id=", userId,
                "&count=", count,
                "&page=", page);
        }

        public virtual IEnumerable<WeiboStatus> ListWeibosWithTrend(string trendName, int count = 20, int page = 1)
        {
            return WithHammock<IEnumerable<WeiboStatus>>("trends/statuses", FormatAsString,
                "?trend_name=", trendName,
                "&count=", count,
                "&page=", page);
        }

        public virtual WeiboTopicId FollowTrend(string trendName)
        {
            return WithHammock<WeiboTopicId>(WebMethod.Post,
                "trends/follow", FormatAsString,
                "?trend_name=", trendName);
        }

        public virtual WeiboResult UnfollowTrend(long trendId)
        {
            return WithHammock<WeiboResult>(WebMethod.Delete,
                "trends/destroy", FormatAsString,
                "?trend_id=", trendId);
        }

        public virtual WeiboTrends ListHourlyTrends(int baseApp = 0)
        {
            return WithHammock<WeiboTrends>("trends/hourly", FormatAsString, "?base_app=", baseApp);
        }

        public virtual WeiboTrends ListDailyTrends(int baseApp = 0)
        {
            return WithHammock<WeiboTrends>("trends/daily", FormatAsString, "?base_app=", baseApp);
        }

        public virtual WeiboTrends ListWeeklyTrends(int baseApp = 0)
        {
            return WithHammock<WeiboTrends>("trends/weekly", FormatAsString, "?base_app=", baseApp);
        }




        public virtual WeiboTrends ListCurrentTrends()
        {
            return WithHammock<WeiboTrends>("trends/current", FormatAsString);
        }

        public virtual WeiboTrends ListCurrentTrends(string exclude)
        {
            return WithHammock<WeiboTrends>("trends/current", FormatAsString, "?exclude=", exclude);
        }       

        public virtual WeiboTrends ListDailyTrends(DateTime date)
        {
            return WithHammock<WeiboTrends>("trends/daily", FormatAsString, "?date=", date);
        }

        public virtual WeiboTrends ListDailyTrends(string exclude)
        {
            return WithHammock<WeiboTrends>("trends/daily", FormatAsString, "?exclude=", exclude);
        }

        public virtual WeiboTrends ListDailyTrends(DateTime date, string exclude)
        {
            return WithHammock<WeiboTrends>("trends/daily", FormatAsString, "?date=", date, "&exclude=", exclude);
        }

        

        public virtual WeiboTrends ListWeeklyTrends(DateTime date)
        {
            return WithHammock<WeiboTrends>("trends/weekly", FormatAsString, "?date=", date);
        }

        public virtual WeiboTrends ListWeeklyTrends(string exclude)
        {
            return WithHammock<WeiboTrends>("trends/weekly", FormatAsString, "?exclude=", exclude);
        }

        public virtual WeiboTrends ListWeeklyTrends(DateTime date, string exclude)
        {
            return WithHammock<WeiboTrends>("trends/weekly", FormatAsString, "?date=", date, "&exclude=", exclude);
        }

        public virtual IEnumerable<WhereOnEarthLocation> ListAvailableTrendsLocations()
        {
            return WithHammock<IEnumerable<WhereOnEarthLocation>>("trends/available", FormatAsString);
        }

        public virtual IEnumerable<WhereOnEarthLocation> ListAvailableTrendsLocations(double lat)
        {
            return WithHammock<IEnumerable<WhereOnEarthLocation>>("trends/available", FormatAsString, "?lat=", lat);
        }

        public virtual IEnumerable<WhereOnEarthLocation> ListAvailableTrendsLocations(double lat, double @long)
        {
            return WithHammock<IEnumerable<WhereOnEarthLocation>>("trends/available", FormatAsString, "?lat=", lat, "&long=", @long);
        }

        public virtual WeiboLocalTrends ListLocalTrendsFor(long woeId)
        {
            return WithHammock<WeiboLocalTrends>("trends/{woe_id}", FormatAsString, "?woe_id=", woeId);
        }
    }
}
